package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.Collect;
import com.example.demo.mapper.CollectMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController     //定义 说明是一个返回js数据的controller
@RequestMapping("/resourceAuditing")     //定义接口统一路由
public class CollectController {
    @Resource
    CollectMapper collectMapper;
    //    数据库，插入数据
    @PostMapping     //定义post接口，接收前台数据
    public Result<?> save(@RequestBody Collect collect){            //@RequestBody  将传过来的js转换为java对象
        collectMapper.insert(collect);    //insert方法，将数插入数据库
        return Result.success();
    }

    //    删除数据接口类
    @DeleteMapping("/{id}")
    public Result<?> update(@PathVariable Long id){
        collectMapper.deleteById(id);
        return Result.success();
    }
}
